package vn.edu.ptithcm.pim.dao;

import vn.edu.ptithcm.pim.dom.Rank;

import java.util.List;

import org.hibernate.LockMode;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

@SuppressWarnings({ "rawtypes" })
public class RankDao extends HibernateDaoSupport {

	public void save(Rank rank) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().save(rank);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void saveOrUpdate(Rank rank) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().saveOrUpdate(rank);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void lock(Rank rank) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().lock(rank, LockMode.NONE);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void delete(Rank rank) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().delete(rank);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Rank merge(Rank rank) {
		try {
			return (Rank) getHibernateTemplate().merge(rank);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Rank findById(java.lang.Long id) {
		try {
			return (Rank) getHibernateTemplate().get(Rank.class, id);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public List findByExample(Rank rank) {
		try {
			return getHibernateTemplate().findByExample("Rank", rank);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public List getAll() {
		try {
			return getHibernateTemplate().loadAll(Rank.class);
		} catch (RuntimeException re) {
			throw re;
		}
	}
}
